/*******************************************************************************
 * Package: com.song.boot.springstudy.thread
 * Type:    MyTStatic
 * Date:    2025/5/22 11:27
 *
 * Copyright (c) 2025 LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.song.boot.springstudy.thread;

/**
 * 功能描述： 静态变量 多线程得时候是共享数据嘛
 *
 * @author Songxianyang
 * @date 2025/5/22 11:27
 */
public class MyTStatic {
    public static void main(String[] args) {
        StaticThread t1 = new StaticThread(2,100);
        StaticThread t2 = new StaticThread();
        // 启动线程
        t1.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t2.start();


    }
}


class StaticThread extends Thread {
    // 声明静态变量num，用于记录num的数量
    static int num = 0;
    int i= 0;

    StaticThread (int num,int i){
        this.num=num;
        this.i = i;
    }
    StaticThread(){

    }


    @Override
    public void run() {
        System.out.println("static::::::"+num);
        System.out.println("int::::::"+i);
    }
}